import { registerAs } from '@nestjs/config';

export default registerAs('database', () => ({
  type: 'mysql',
  host: process.env.DB_HOST || 'localhost', // 默认值为 'localhost'
  port: parseInt(process.env.DB_PORT || '3306', 10), // 默认值为 '3306'
  username: process.env.DB_USERNAME || 'root', // 默认值为 'root'
  password: process.env.DB_PASSWORD || '123456', // 默认值为 'password'
  database: process.env.DB_NAME || 'hdq', // 默认值为 'test'
  entities: [__dirname + '/../**/*.entity{.ts,.js}'],
  synchronize: process.env.NODE_ENV === 'development', // 仅在开发环境同步
}));